/**
 * Created by yuming619 on 2016/11/25.
 */
angular.module('mealplan.service.order', ['ngResource'])
//order
    .service('CmtOrderService', ['$resource', function ($resource) {
        var resource = $resource(cmturl + "orders/:orderid");
        this.selectbyall = function () {
            return resource.query();
        };
        //添加订单
        this.add = function (order, success, error) {
            return resource.save({}, order, success, error);
        };
        //更新订单
        this.update = function (id, order, success, error) {
            return resource.save({orderid: id}, order, success, error);
        };
        //通过Id 查询订单
        this.selectbyid = function (id) {
            return resource.get({orderid: id});
        };

        this.getstate = function (status, paystate, time_start, time_end, type) {
            var resource = $resource(cmturl + "orders/bystate");
            return resource.query({
                status: status,
                paystate: paystate,
                time_start: time_start,
                time_end: time_end,
                type: type
            });
        };
        //通过id,删除shop
        this.deletebyid = function (id) {
            return resource.remove({orderid: id});
        }
    }])


